home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-11 / logicals.zip / LOGICALS.TXT < prev    next >
Text File  |  1993-01-04  |  14KB  |  402 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.                                LOGICALS
  8.  
  9.                            -- THE MANUAL --
  10.  
  11.                                05/14/90 Logicals -- The Manual --                                             Page:   2
  12. Tuesday  May 15, 1990   10:55:37 am
  13.  
  14.  
  15.  
  16. The functions here were written to add some of the bitwise functionality found
  17. in Quicksilver to Clipper.  They are just a few simple functions to identify
  18. and set integer bit masks, as well as to combine masks logically with AND, OR
  19. and XOR functions.  They can be quite useful when doing BIOS/DOS calls, and
  20. using a preprocessor to name various bit masks.
  21.  
  22. Logical Functions Included in LOGICALS.LIB:
  23.  
  24. bitwand() - Bitwise AND of two integers.
  25. bitwor() - Bitwise OR of two integers.
  26. bitwxor() - Bitwise XOR of two integers.
  27.  
  28. bitset() - Test whether specified bit is SET (1).
  29. bitclear() - Test whether specified bit is CLEAR (0).
  30.  
  31. setbit() - Set specified bit to 1.
  32. clearbit() - Clear specified bit to 0.
  33.  
  34. bitmap() - Fills first 16 positions of an array with True/False indications
  35.             of whether corresponding bit is set.
  36.  
  37.      Bitset() and setbit(), as well as bitclear() and clearbit(), are easy to
  38. keep straight in your mind if you look closely at the names.  The testing
  39. functions bitset() and bitclear() begin with a noun (existence), the setting
  40. functions setbit() and clearbit(), begin with verbs (action).
  41.  
  42. Sample linking batch files are also included - clipem.bat for Microsoft Link,
  43. and cliplink.bat for Sage's PLink86 Plus.  To install, just copy LOGICALS.LIB
  44. into the same directory as CLIPPER.LIB and EXTEND.LIB.
  45. Logicals -- The Manual -- Registration                                Page:   3
  46. Tuesday  May 15, 1990   10:55:37 am
  47.  
  48. Registration:
  49.  
  50. The functions in this mini-library are free for your use.  However,
  51. they are also still under my copyright, and their source shall not
  52. appear in any shareware version.  
  53.  
  54. I am also putting the finishing touches on more complete libraries
  55. for Clipper, providing LaserJet control and mouse functions.  To
  56. register, and receive information on these other products, please
  57. send a copy of the form below.  Registration with source (if you
  58. really need it) is sent for a donation of $7.50 and includes 25% off
  59. the registration with source for the previously mentioned products.
  60.  
  61. REGISTRATION (Logicals)
  62. -----------------------
  63.  
  64. Name:    __________________________________________     Date: __/__/__
  65.        
  66. Address: __________________________________________
  67.  
  68. Address: __________________________________________
  69.  
  70. City:    _______________________________,  State: _______  Zip: ________
  71.  
  72. Phone Number: (_____)  _____ - ________
  73.  
  74. Computer Type: ______________________________   DOS Version: ___________
  75.  
  76. Optional:
  77.  
  78. Company:  __________________________________________
  79.  
  80. Position: __________________________________________
  81.  
  82. Work Phone: (_____)  _____ - ________
  83.  
  84.  
  85. _____ No donation.  Registration Only
  86.  
  87. _____ $7.50+ donation.  Please send me the source.
  88.  
  89. Send to: R. L. Korbeck,  17233 Hemmingway St.  Van Nuys, CA  91406
  90. Logicals -- The Manual -- BitWAnd()                                   Page:   4
  91. Tuesday  May 15, 1990   10:55:37 am
  92.  
  93. Function Name: BitWAnd()
  94.  
  95. Function Type: Numeric (Integer)
  96.  
  97. Syntax:        BitWAnd(Parameter 1, Parameter 2)
  98.  
  99.                  Parameter 1 - Numeric (Integer) - Number Input
  100.                  Parameter 2 - Numeric (Integer) - Bit Mask
  101.  
  102. Object File:   logical1.obj
  103.  
  104. Description:   BitWAnd() takes two integers as parameters, returning
  105.                  an integer which is the result of a bitwise AND of the
  106.                  input integers.  If fewer than two parameters are input,
  107.                  BitWAnd() returns 0.
  108.  
  109. Examples:      ? "BitWAnd(255, 15) = "
  110.                ?? trim(str(bitwand(255, 15)))
  111.                ? "BitWAnd(255) = "
  112.                ?? trim(str(bitwand(255)))
  113.                ? "BitWAnd(65, 33) = "
  114.                ?? trim(str(bitwand(65, 33)))
  115.  
  116.                results in:
  117.  
  118.                BitWAnd(255, 15) = 15
  119.                BitWAnd(255) = 0
  120.                BitWAnd(65, 33) = 1
  121.  
  122. Logicals -- The Manual -- BitWOr()                                    Page:   5
  123. Tuesday  May 15, 1990   10:55:37 am
  124.  
  125. Function Name: BitWOr()
  126.  
  127. Function Type: Numeric (Integer)
  128.  
  129. Syntax:        BitWOr(Parameter 1, Parameter 2)
  130.  
  131.                  Parameter 1 - Numeric (Integer) - Number Input 
  132.                  Parameter 2 - Numeric (Integer) - Bit Mask
  133.  
  134. Object File:   logical2.obj
  135.  
  136. Description:   BitWOr() takes two integers as parameters, returning
  137.                  an integer which is the result of a bitwise OR of the
  138.                  input integers.  If fewer than two parameters are input,
  139.                  BitWOr() returns 0.
  140.  
  141. Examples:      ? "BitWOr(255, 15) = "
  142.                ?? trim(str(bitwor(255, 15)))
  143.                ? "BitWOr(255) = "
  144.                ?? trim(str(bitwor(255)))
  145.                ? "BitWOr(65, 33) = "
  146.                ?? trim(str(bitwor(65, 33)))
  147.  
  148.                results in:
  149.  
  150.                BitWOr(255, 15) = 15
  151.                BitWOr(255) = 0
  152.                BitWOr(65, 33) = 97
  153.  
  154. Logicals -- The Manual -- BitWXOr()                                   Page:   6
  155. Tuesday  May 15, 1990   10:55:37 am
  156.  
  157. Function Name: BitWXOr()
  158.  
  159. Function Type: Numeric (Integer)
  160.  
  161. Syntax:        BitWXOr(Parameter 1, Parameter 2)
  162.  
  163.                  Parameter 1 - Numeric (Integer) - Number Input
  164.                  Parameter 2 - Numeric (Integer) - Bit Mask
  165.  
  166. Object File:   logical3.obj
  167.  
  168. Description:   BitWXOr() takes two integers as parameters, returning
  169.                  an integer which is the result of a bitwise XOR of the
  170.                  input integers.  If fewer than two parameters are input,
  171.                  BitWXOr() returns 0.
  172.  
  173. Examples:      ? "BitWXOr(255, 15) = "
  174.                ?? trim(str(bitwxor(255, 15)))
  175.                ? "BitWXOr(255) = "
  176.                ?? trim(str(bitwxor(255)))
  177.                ? "BitWXOr(65, 33) = "
  178.                ?? trim(str(bitwxor(65, 33)))
  179.  
  180.                results in:
  181.  
  182.                BitWXOr(255, 15) = 240
  183.                BitWXOr(255) = 0
  184.                BitWXOr(65, 33) = 96
  185.  
  186. Logicals -- The Manual -- BitSet()                                    Page:   7
  187. Tuesday  May 15, 1990   10:55:37 am
  188.  
  189. Function Name: BitSet()
  190.  
  191. Function Type: Logical
  192.  
  193. Syntax:        BitSet(Parameter 1, Parameter 2)
  194.  
  195.                  Parameter 1 - Numeric (Integer) - Number Input
  196.                  Parameter 2 - Numeric (Integer) - Bit to Check
  197.  
  198. Object File:   logical4.obj
  199.  
  200. Description:   BitSet() takes two integers as parameters.  The first
  201.                  is an integer value, the second the number of the bit
  202.                  to be checked.  The bit to be checked must be in the
  203.                  range 0 - 15.  If the corresponding bit is set, then
  204.                  BitSet() returns True.  If the bit is not set, or if 
  205.                  the requested bit number is not in the 0 - 15 range,
  206.                  or if fewer than two parameters are input, then BitSet()
  207.                  returns False.
  208.  
  209. Examples:      ? "BitSet(255, 15) = "
  210.                ?? bitset(255, 15)
  211.                ? "BitSet(255, 1) = "
  212.                ?? bitset(255, 1)
  213.                ? "BitSet(65, 33) = "
  214.                ?? bitset(65, 33)
  215.                ? "BitSet(65) = "
  216.                ?? bitset(65)
  217.  
  218.                results in:
  219.  
  220.                BitSet(255, 15) = .F.
  221.                BitSet(255, 0) = .T.
  222.                BitSet(65, 33) = .F.
  223.                BitSet(65) = .F.
  224.  
  225. Logicals -- The Manual -- BitClear()                                  Page:   8
  226. Tuesday  May 15, 1990   10:55:37 am
  227.  
  228. Function Name: BitClear()
  229.  
  230. Function Type: Logical
  231.  
  232. Syntax:        BitClear(Parameter 1, Parameter 2)
  233.  
  234.                  Parameter 1 - Numeric (Integer) - Number Input
  235.                  Parameter 2 - Numeric (Integer) - Bit to Check
  236.  
  237. Object File:   logical5.obj
  238.  
  239. Description:   BitClear() takes two integers as parameters.  The first
  240.                  is an integer value, the second the number of the bit
  241.                  to be checked.  The bit to be checked must be in the
  242.                  range 0 - 15.  If the corresponding bit is clear, then
  243.                  BitClear() returns True.  If the bit is set, or if 
  244.                  the requested bit number is not in the 0 - 15 range,
  245.                  or if fewer than two parameters are input, then
  246.                  BitClear() returns False.
  247.  
  248. Examples:      ? "BitClear(255, 15) = "
  249.                ?? bitclear(255, 15)
  250.                ? "BitClear(255, 1) = "
  251.                ?? bitclear(255, 1)
  252.                ? "BitClear(65, 33) = "
  253.                ?? bitclear(65, 33)
  254.                ? "BitClear(65) = "
  255.                ?? bitclear(65)
  256.  
  257.                results in:
  258.  
  259.                BitClear(255, 15) = .T.
  260.                BitClear(255, 0) = .F.
  261.                BitClear(65, 33) = .F.
  262.                BitClear(65) = .F.
  263.  
  264. Logicals -- The Manual -- SetBit()                                    Page:   9
  265. Tuesday  May 15, 1990   10:55:37 am
  266.  
  267. Function Name: SetBit()
  268.  
  269. Function Type: Numeric (Integer)
  270.  
  271. Syntax:        SetBit(Parameter 1, Parameter 2)
  272.  
  273.                  Parameter 1 - Numeric (Integer) - Number Input
  274.                  Parameter 2 - Numeric (Integer) - Bit to be Set
  275.  
  276. Object File:   logical6.obj
  277.  
  278. Description:   SetBit() takes two integers as parameters, returning
  279.                  an integer which is the number input as parameter 1
  280.                  with the bit specified by parameter 2 being set.  The
  281.                  number input as Parameter 2 must be in the range 0 - 15.
  282.                  If the bit was already set, the result is the same as
  283.                  parameter 1.  If it was not previously set, the result
  284.                  is the same as (Param1 + 2^^Param2).  If fewer than two
  285.                  parameters are input, or if Parameter 2 is not in the
  286.                  range 0 - 15, then SetBit() returns 0.
  287.  
  288. Examples:      ? "SetBit(255, 15) = "
  289.                ?? trim(str(setbit(255, 15)))
  290.                ? "SetBit(255) = "
  291.                ?? trim(str(setbit(255)))
  292.                ? "SetBit(255, 1) = "
  293.                ?? trim(str(setbit(255)))
  294.                ? "SetBit(255, 9) = "
  295.                ?? trim(str(setbit(255)))
  296.                ? "SetBit(65, 33) = "
  297.                ?? trim(str(setbit(65, 33)))
  298.  
  299.                results in:
  300.  
  301.                SetBit(255, 15) = 33023
  302.                SetBit(255) = 0
  303.                SetBit(255, 1) = 255
  304.                SetBit(255, 9) = 767
  305.                SetBit(65, 33) = 0
  306.  
  307. Logicals -- The Manual -- ClearBit()                                  Page:  10
  308. Tuesday  May 15, 1990   10:55:37 am
  309.  
  310. Function Name: ClearBit()
  311.  
  312. Function Type: Numeric (Integer)
  313.  
  314. Syntax:        ClearBit(Parameter 1, Parameter 2)
  315.  
  316.                  Parameter 1 - Numeric (Integer) - Number Input
  317.                  Parameter 2 - Numeric (Integer) - Bit to be Cleared
  318.  
  319. Object File:   logical7.obj
  320.  
  321. Description:   ClearBit() takes two integers as parameters, returning
  322.                  an integer which is the number input as parameter 1
  323.                  with the bit specified by parameter 2 being cleared.
  324.                  The number input as Parameter 2 must be in the range
  325.                  0 - 15.  If the bit was already clear, the result is
  326.                  the same as parameter 1.  If it was not previously
  327.                  cleared, the result is the same as (Param1 - 2^^Param2).
  328.                  If fewer than two parameters are input, or if Parameter
  329.                  2 is not in the range 0 - 15, then ClearBit() returns 0.
  330.  
  331. Examples:      ? "ClearBit(255, 15) = "
  332.                ?? trim(str(clearbit(255, 15)))
  333.                ? "ClearBit(255) = "
  334.                ?? trim(str(clearbit(255)))
  335.                ? "ClearBit(255, 1) = "
  336.                ?? trim(str(clearbit(255)))
  337.                ? "ClearBit(255, 9) = "
  338.                ?? trim(str(clearbit(255)))
  339.                ? "ClearBit(65, 33) = "
  340.                ?? trim(str(clearbit(65, 33)))
  341.  
  342.                results in:
  343.  
  344.                ClearBit(255, 15) = 255
  345.                ClearBit(255) = 0
  346.                ClearBit(255, 1) = 254
  347.                ClearBit(255, 9) = 255
  348.                ClearBit(65, 33) = 0
  349.  
  350. Logicals -- The Manual -- BitMap()                                    Page:  11
  351. Tuesday  May 15, 1990   10:55:37 am
  352.  
  353. Function Name: BitMap()
  354.  
  355. Function Type: Logical
  356.  
  357. Syntax:        BitMap(Parameter 1, Parameter 2)
  358.  
  359.                  Parameter 1 - Numeric (Integer) - Number Input
  360.                  Parameter 2 - Array - Array to Store Values in.
  361.  
  362. Object File:   logical8.obj
  363.  
  364. Description:   BitMap() uses two parameters, the number for which the
  365.                  map is being generated, and the array that holds the
  366.                  map.  BitMap() returns a value of False if there are
  367.                  less than two parameters passed, if the parameters are
  368.                  not the correct types, or if the array is not large
  369.                  enough to hold the sixteen values.  BitMap() doesn't
  370.                  care if the array is larger than sixteen positions.
  371.                  BitMap() will return a logical True value in all other
  372.                  circumstances.
  373.  
  374. Examples:      declare Example[16]
  375.                BitMap(255, Example)
  376.                for n = 1 to 16
  377.                  ShowString = "Bit[" + trim(int(n-1)) + "] = "
  378.                  ? ShowString
  379.                  ?? Example[n]
  380.                next
  381.  
  382.                results in:
  383.  
  384.                Bit[0] = .T.
  385.                Bit[1] = .T.
  386.                Bit[2] = .T.
  387.                Bit[3] = .T.
  388.                Bit[4] = .T.
  389.                Bit[5] = .T.
  390.                Bit[6] = .T.
  391.                Bit[7] = .T.
  392.                Bit[8] = .F.
  393.                Bit[9] = .F.
  394.                Bit[10] = .F.
  395.                Bit[11] = .F.
  396.                Bit[12] = .F.
  397.                Bit[13] = .F.
  398.                Bit[14] = .F.
  399.                Bit[15] = .F.
  400.  
  401.  
  402.